<h1>新增任务</h1>

<% provide(micropost: @micropost) %>

<div class="row">

  <div class="col-md-6 col-md-offset-3">

<%= form_for(@micropost, url: task_new_path, local: true) do |form| %>
  <% if @micropost.errors.any? %>
    <div id="error_explanation">
    <div class="alert alert-danger">

      <%= pluralize(@micropost.errors.count, "error") %> prohibited this micropost from being saved
    </div>
      <ul>
      <% @micropost.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

    <%= form.label :jobnumber, "工作令号" %>
    <%= form.select :jobnumber_id, Jobnumber.all.collect {|j| [j.name, j.id]},  :prompt => 'Select One', class: 'form-control' %>

    <%= form.label :category, "大类" %>
    <%= form.collection_select :category_id, Category.order(:name), :id, :name, :prompt => 'Select One', class: 'form-control' %>

    <%= form.label :subcategory, "分类" %>
    <%= form.grouped_collection_select :subcategory_id, Category.order(:name), :subcategories, :name, :id, :name, :prompt => 'Select One', class: 'form-control' %>



    <%= form.label :task, "任务" %>
    <%= form.text_area :task, class: 'form-control' %>

    <%= form.label :cost, "工时 (小时) " %>
    <%= form.number_field :cost, class: 'form-control', step: :any %>



    <%= form.label :date %>
    <%= form.date_field :date, class: 'form-control' %>

    <%= form.submit "submit", class: 'btn btn-primary' %>

<% end %>

  </div>


</div>
